import java.util.concurrent.Semaphore;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-10-01
 * Time: 16:26
 */
//Semaphore  信号量
public class Demo27 {
    public static void main(String[] args) throws InterruptedException {
        //指定计数器的初始值
        Semaphore semaphore=new Semaphore(4);
        semaphore.acquire();
        System.out.println("执行了一次P操作");
        semaphore.acquire();
        System.out.println("执行了一次P操作");
        semaphore.acquire();
        System.out.println("执行了一次P操作");
        semaphore.acquire();
        System.out.println("执行了一次P操作");
        semaphore.acquire();
        System.out.println("执行了一次P操作");
    }
}
